function checkLocation(seq) {
	
			str     = eval('document.sortProcessForm.select_'+seq+'.checked');	
			var cnt = document.sortProcessForm.count.value;
			var row_checked = eval('document.sortProcessForm.laserRepairAllowed_'+seq+'.checked');
			var maxVal = 0;
			 if(cnt!=1)
			{	
				var rawCheck = eval('document.sortProcessForm.laserRepairAllowed_'+seq);
				
				if(str==false){
                    document.sortProcessForm.priority[seq].disabled=true;
                    document.sortProcessForm.split[seq].disabled=true;
                    document.sortProcessForm.capacityWeek[seq].disabled=true;
                    document.sortProcessForm.normalCost[seq].disabled=true;
                    document.sortProcessForm.expressCost[seq].disabled=true;
                    document.sortProcessForm.locationName[seq].disabled=true;
                    document.sortProcessForm.normalCycleTime[seq].disabled=true;
                    document.sortProcessForm.expressCycleTime[seq].disabled=true;
                    rawCheck.disabled=true;
                    document.sortProcessForm.laserRepairCost[seq].disabled=true;

					// added to set the default priority by ravikanth
					maxVal =  document.sortProcessForm.priority[seq].value;
					for ( var y =0 ; y < cnt ; y++ )
					{
						temp   = document.sortProcessForm.priority[y].value;
						if( temp > maxVal && maxVal != 0)
						{
							document.sortProcessForm.priority[y].value = parseInt(document.sortProcessForm.priority[y].value) -1;
						}
					}
					document.sortProcessForm.priority[seq].value='';
				}
				if(str==true){
                    document.sortProcessForm.priority[seq].disabled=false;
                    document.sortProcessForm.split[seq].disabled=false;
                    document.sortProcessForm.capacityWeek[seq].disabled=false;
                    document.sortProcessForm.normalCost[seq].disabled=false;
                    document.sortProcessForm.expressCost[seq].disabled=false;
                    //document.sortProcessForm.locationName[seq].disabled=false;
                    document.sortProcessForm.normalCycleTime[seq].disabled=false;
                    document.sortProcessForm.expressCycleTime[seq].disabled=false;
                    rawCheck.disabled=false;
                    if(row_checked==false){
                         document.sortProcessForm.laserRepairCost[seq].disabled=true;
                    }
                    if(row_checked==true){
                         document.sortProcessForm.laserRepairCost[seq].disabled=false;
                    }

					// added to set the default priority by ravikanth
					for ( var y =0 ; y < cnt ; y++ )
					{
						temp   = document.sortProcessForm.priority[y].value;
						//alert(temp);
						if( temp > maxVal)
						{
							maxVal = temp
						}
					}		
					document.sortProcessForm.priority[seq].value= parseInt(maxVal)+1 ;
				}
			}
			
		   else{
            var row_checked = eval('document.sortProcessForm.laserRepairAllowed_0.checked');
			if(str==false){
                    document.sortProcessForm.priority.disabled=true;
                    document.sortProcessForm.split.disabled=true;
                    document.sortProcessForm.capacityWeek.disabled=true;
                    document.sortProcessForm.normalCost.disabled=true;
                    document.sortProcessForm.expressCost.disabled=true;
                    document.sortProcessForm.locationName.disabled=true;
                    document.sortProcessForm.normalCycleTime.disabled=true;
                    document.sortProcessForm.expressCycleTime.disabled=true;
                    document.sortProcessForm.laserRepairAllowed_0.disabled=true;
                    document.sortProcessForm.laserRepairCost.disabled=true;
					document.sortProcessForm.priority.value='';
				}
				if(str==true){
                    document.sortProcessForm.priority.disabled=false;
                    document.sortProcessForm.split.disabled=false;
                    document.sortProcessForm.capacityWeek.disabled=false;
                    document.sortProcessForm.normalCost.disabled=false;
                    document.sortProcessForm.expressCost.disabled=false;
                    //document.sortProcessForm.locationName.disabled=false;
                    document.sortProcessForm.normalCycleTime.disabled=false;
                    document.sortProcessForm.expressCycleTime.disabled=false;
                    document.sortProcessForm.laserRepairAllowed_0.disabled=false;
                    if(row_checked==false){
                        document.sortProcessForm.laserRepairCost.disabled=true;
                    }
                    if(row_checked==true){
                        document.sortProcessForm.laserRepairCost.disabled=false;
                    }
					document.sortProcessForm.priority.value=1;
				}
		   }
}

function checkLaser(seq) {
	str     = eval('document.sortProcessForm.laserRepairAllowed_'+seq+'.checked');
	var cnt = document.sortProcessForm.count.value;
	if(cnt!=1)
	{
		if(str==false){
			document.sortProcessForm.laserRepairCost[seq].disabled=true;
		}
		if(str==true){
			document.sortProcessForm.laserRepairCost[seq].disabled=false;
		}
	}
	else
	{
		if(str==false)
		{
			document.sortProcessForm.laserRepairCost.disabled=true;
		}
		if(str==true)
		{
			document.sortProcessForm.laserRepairCost.disabled=false;
		}
    }
}

function whileLoad()
{

	var cnt = document.sortProcessForm.count.value;

	if(cnt==1)
	{ 
		str     = eval('document.sortProcessForm.select_0.checked');
		str_raw = eval('document.sortProcessForm.laserRepairAllowed_0.checked');
		var rawCheck = eval('document.sortProcessForm.laserRepairAllowed_0');
		
		if(str==false){
				document.sortProcessForm.priority.disabled=true;
				document.sortProcessForm.split.disabled=true;
				document.sortProcessForm.capacityWeek.disabled=true;
				document.sortProcessForm.normalCost.disabled=true;
				document.sortProcessForm.expressCost.disabled=true;
				document.sortProcessForm.locationName.disabled=true;
				document.sortProcessForm.normalCycleTime.disabled=true;
				document.sortProcessForm.expressCycleTime.disabled=true;
				rawCheck.disabled=true;
				//if(str_raw==false){
				document.sortProcessForm.laserRepairCost.disabled=true;
				//}
				}

				if(str==true){
				document.sortProcessForm.priority.disabled=false;
				document.sortProcessForm.split.disabled=false;
				document.sortProcessForm.capacityWeek.disabled=false;
				document.sortProcessForm.normalCost.disabled=false;
				document.sortProcessForm.expressCost.disabled=false;
				//document.sortProcessForm.locationName.disabled=false;
				document.sortProcessForm.normalCycleTime.disabled=false;
				document.sortProcessForm.expressCycleTime.disabled=false;
				rawCheck.disabled=false;
				if(str_raw==true){
				document.sortProcessForm.laserRepairCost.disabled=false;
				}
				else{
				document.sortProcessForm.laserRepairCost.disabled=true;
				}
			    //document.sortProcessForm.laserRepairCost.disabled=false;
			}

	}else{

	    for(var i=0;i<cnt;i++){
				str     = eval('document.sortProcessForm.select_'+i+'.checked');
				str_raw = eval('document.sortProcessForm.laserRepairAllowed_'+i+'.checked');
				var rawCheck = eval('document.sortProcessForm.laserRepairAllowed_'+i);
				
				if(str==false){
                    document.sortProcessForm.priority[i].disabled=true;
                    document.sortProcessForm.split[i].disabled=true;
                    document.sortProcessForm.capacityWeek[i].disabled=true;
                    document.sortProcessForm.normalCost[i].disabled=true;
                    document.sortProcessForm.expressCost[i].disabled=true;
                    document.sortProcessForm.locationName[i].disabled=true;
                    document.sortProcessForm.normalCycleTime[i].disabled=true;
                    document.sortProcessForm.expressCycleTime[i].disabled=true;
                    rawCheck.disabled=true;
                    document.sortProcessForm.laserRepairCost[i].disabled=true;
				}
				else if(str==true){
                    document.sortProcessForm.priority[i].disabled=false;
                    document.sortProcessForm.split[i].disabled=false;
                    document.sortProcessForm.capacityWeek[i].disabled=false;
                    document.sortProcessForm.normalCost[i].disabled=false;
                    document.sortProcessForm.expressCost[i].disabled=false;
                    //document.sortProcessForm.locationName[i].disabled=false;
                    document.sortProcessForm.normalCycleTime[i].disabled=false;
                    document.sortProcessForm.expressCycleTime[i].disabled=false;
                    rawCheck.disabled=false;
                    if(str_raw==true){
                        document.sortProcessForm.laserRepairCost[i].disabled=false;
                    }else{
                        document.sortProcessForm.laserRepairCost[i].disabled=true;
                    }
			}
	    }
	}
}

function saveProcess(theForm,action)
{
	var pa						= document.getElementById("message");
	var cnt						= theForm.count.value;
	var std_unit_cost			= theForm["sortProcess.stndUnitCost"].value;
	var lot_scrap_yield_limit   = theForm["sortProcess.lotScrapYieldLimit"].value;
	var lot_hold_yield_limit	= theForm["sortProcess.lotHoldYieldLimit"].value;
	var vendorPriority			=  null;

	if(action == 'save')
	{
		var vendorCnt				= 0;
	
		// added by ravikanth on 30-Sep-2003
		if(trim(theForm["sortProcess.sortProductName"].value)=='')
		{
			pa.innerHTML = "Sort Part Number cannot be null or contain spaces ";	
			theForm["sortProcess.sortProductName"].focus();
			return;
		}

		if( typeof theForm["locationName"].length == 'undefined' )
		{
			if ( theForm["select_0"].checked+"" == "true" )
			{
				vendorCnt++;
			}
			
			if( vendorCnt > 0 && ( theForm["priority"].value =='0' || theForm["priority"].value.trim().length == 0 ) )
			{
				pa.innerHTML = "Priority cannot 0 or empty ";	
				theForm["priority"].value='';
				theForm["priority"].focus();
				return; 
			}
		}
		else
		{
			vendorPriority = new Array(theForm["locationName"].length);

			for (var x=0 ; x < theForm["locationName"].length ; x++ )
			{
				var temp = eval('theForm["select_'+x+'"]');

				if( temp.checked+"" == "true" )
				{
					vendorCnt++;
					if (document.sortProcessForm.priority[x].value == 0 || document.sortProcessForm.priority[x].value.trim().length == 0 )
					{
						pa.innerHTML = "Vendor priority cannot 0 or empty ";	
						document.sortProcessForm.priority[x].value = '';
						document.sortProcessForm.priority[x].focus();
						return; 
					}
					vendorPriority[x] = document.sortProcessForm.priority[x].value
				}
			}
		}

		if( vendorCnt == 0)
		{
			pa.innerHTML = "Should select atleast one vendor";	
			return; 
		}

		if( vendorCnt > 1 )
		{
			
			for ( y=0 ; y < vendorPriority.length -1 ; y++ )
			{
				for ( z = y+1 ; z < vendorPriority.length ; z++ )
				{
					if( vendorPriority[y] != null && vendorPriority[z] != null && vendorPriority[y] != 0 && vendorPriority[z] !=0 )
					{
						if ( vendorPriority[z] == vendorPriority[y])
						{
							pa.innerHTML = "Two vendor priorities cannot be same ";	
							return; 
						}
					}
				}
			}
		}

		var flag = checkDupInProduct(theForm["sortProcess.sortProductName"],theForm["sortProcess.dupProductName"]);
		if( flag != -1 )
		{
			if( typeof theForm["sortProcess.dupProductName"].length == 'undefined' )
			{
				theForm["sortProcess.dupProductName"].focus();
			}
			else
			{
				theForm["sortProcess.dupProductName"][flag].focus();	
			}
			pa.innerHTML = "Two Part numbers cannot be same";	
			return; 
		}
	    theForm.action.value = "SaveSortProcess";
	}
    else if(action == 'binsetup')
	{
		theForm.action.value = "SortBinSetup";
	}

	if(std_unit_cost!=''){
		if(!isFloat(std_unit_cost)){	
 	    pa.innerHTML = "Please enter valid Standard Unit Cost,It must be float";
		theForm["sortProcess.stndUnitCost"].select();
		theForm.theForm["sortProcess.stndUnitCost"].focus();
		return;
		}	
	}
	if(lot_scrap_yield_limit!=''){
		if(!isFloat(lot_scrap_yield_limit)){	
 	    pa.innerHTML = "Please enter valid Lot Scrap Yield Limit,It must be float";
		theForm["sortProcess.lotScrapYieldLimit"].select();
		theForm["sortProcess.lotScrapYieldLimit"].focus();
		return;
		}	
	}

	if(lot_hold_yield_limit!=''){
		if(!isFloat(lot_hold_yield_limit)){	
 	    pa.innerHTML = "Please enter valid Lot Hold Yield Limit,It must be Float";
		theForm["sortProcess.lotHoldYieldLimit"].select();
		theForm["sortProcess.lotHoldYieldLimit"].focus();
		return;
		}	
	}

	if(cnt==1)
	{ 
		str     = eval('document.sortProcessForm.select_0.checked');
		
		if(str==true){
                var priority		= document.sortProcessForm.priority.value;
				var split			= document.sortProcessForm.split.value;
				var capacity_week   = document.sortProcessForm.capacityWeek.value;
				var normal_cost		= document.sortProcessForm.normalCost.value;
				var express_cost	= document.sortProcessForm.expressCost.value;
				var normal_time		= document.sortProcessForm.normalCycleTime.value;
				var express_time	= document.sortProcessForm.expressCycleTime.value;
						
				str_raw     = eval('document.sortProcessForm.laserRepairAllowed_0.checked');

				if(priority!=''){
				if (!isInteger(priority)){
				pa.innerHTML = "Please enter valid Priority,It must be number";
				document.sortProcessForm.priority.select();
				document.sortProcessForm.priority.focus();
				return;
				}
			}
    		if(split!=''){
				if (!isFloat(split)){
				pa.innerHTML = "Please enter valid Split,It must be float";
				document.sortProcessForm.split.select();
				document.sortProcessForm.split.focus();
				return;
				}
			}
			if(capacity_week!=''){
				if (!isInteger(capacity_week)){
				pa.innerHTML = "Please enter valid Capacity Per Week,It must be number";
				document.sortProcessForm.capacityWeek.select();
				document.sortProcessForm.capacityWeek.focus();
				return;
				}
			}
			if(normal_cost!=''){
				if (!isFloat(normal_cost)){
				pa.innerHTML = "Please enter valid Normal Cost,It must be float";
				document.sortProcessForm.normalCost.select();
				document.sortProcessForm.normalCost.focus();
				return;
				}
			}

			if(express_cost!=''){
				if (!isFloat(express_cost)){
				pa.innerHTML = "Please enter valid Express Cost,It must be float";
				document.sortProcessForm.expressCost.select();
				document.sortProcessForm.expressCost.focus();
				return;
				}
			}

				if(normal_time!=''){
				if (!isInteger(normal_time)){
				pa.innerHTML = "Please enter valid Normal Time,It must be number";
				document.sortProcessForm.normalCycleTime.select();
				document.sortProcessForm.normalCycleTime.focus();
				return;
				}
				}

				if(express_time!=''){
				if (!isInteger(express_time)){
				pa.innerHTML = "Please enter valid Express Time,It must be number";
				document.sortProcessForm.expressCycleTime.select();
				document.sortProcessForm.expressCycleTime.focus();
				return;
				}
				}

				
				if(str_raw==true){
				cost=document.sortProcessForm.laserRepairCost.value;
				
				if(cost!=''){
				if (!isFloat(cost)){
				pa.innerHTML = "Please enter valid Raw Material Min Level,It must be number";
				document.sortProcessForm.laserRepairCost.select();
				return;
				}
				}
			

				}
				
			}

	}


	else{
		
	for(var i=0;i<cnt;i++){
			
				str     = eval('document.sortProcessForm.select_'+i+'.checked');
				
				if(str==true){
				var priority		= document.sortProcessForm.priority[i].value;
				var split			= document.sortProcessForm.split[i].value;
				var capacity_week   = document.sortProcessForm.capacityWeek[i].value;
				var normal_cost		= document.sortProcessForm.normalCost[i].value;
				var express_cost	= document.sortProcessForm.expressCost[i].value;
				var normal_time		= document.sortProcessForm.normalCycleTime[i].value;
				var express_time	= document.sortProcessForm.expressCycleTime[i].value;
				str_raw				= eval('document.sortProcessForm.laserRepairAllowed_'+i+'.checked');
		
				if(priority!=''){
				if (!isInteger(priority)){
				pa.innerHTML = "Please enter valid Priority,It must be number";
				document.sortProcessForm.priority[i].select();
				document.sortProcessForm.priority[i].focus();
				return;
				}
				}

				if(split!=''){
				if (!isFloat(split)){
				pa.innerHTML = "Please enter valid Split,It must be float";
				document.sortProcessForm.split[i].select();
				document.sortProcessForm.split[i].focus();
				return;
				}
				}

				if(capacity_week!=''){
				if (!isInteger(capacity_week)){
				pa.innerHTML = "Please enter valid Capacity Per Week,It must be number";
				document.sortProcessForm.capacityWeek[i].select();
				document.sortProcessForm.capacityWeek[i].focus();
				return;
				}
				}

				if(normal_cost!=''){
				if (!isFloat(normal_cost)){
				pa.innerHTML = "Please enter valid Normal Cost,It must be float";
				document.sortProcessForm.normalCost[i].select();
				document.sortProcessForm.normalCost[i].focus();
				return;
				}
				}

				if(express_cost!=''){
				if (!isFloat(express_cost)){
				pa.innerHTML = "Please enter valid Express Cost,It must be float";
				document.sortProcessForm.expressCost[i].select();
				document.sortProcessForm.expressCost[i].focus();
				return;
				}
				}

				if(normal_time!=''){
				if (!isInteger(normal_time)){
				pa.innerHTML = "Please enter valid Normal Time,It must be number";
				document.sortProcessForm.normalCycleTime[i].select();
				document.sortProcessForm.normalCycleTime[i].focus();
				return;
				}
				}

				if(express_time!=''){
				if (!isInteger(express_time)){
				pa.innerHTML = "Please enter valid Express Time,It must be number";
				document.sortProcessForm.expressCycleTime[i].select();
				document.sortProcessForm.expressCycleTime[i].focus();
				return;
				}
				}

				
				if(str_raw==true){
				cost=document.sortProcessForm.laserRepairCost[i].value;
				
				if(cost!=''){
				if (!isFloat(cost)){
				pa.innerHTML = "Please enter valid Laser Repair Cost,It must be float";
				document.sortProcessForm.laserRepairCost[i].select();
				document.sortProcessForm.laserRepairCost[i].focus();
				return;
				}
				}
				}


				}
				
	}

	}
	

	if(cnt!=1){
	for(var i=0;i<cnt;i++){

				str = eval('document.sortProcessForm.select_'+i);
				str_raw = eval('document.sortProcessForm.laserRepairAllowed_'+i);
				document.sortProcessForm.priority[i].disabled=false;
				document.sortProcessForm.split[i].disabled=false;
				document.sortProcessForm.capacityWeek[i].disabled=false;
				document.sortProcessForm.normalCost[i].disabled=false;
				document.sortProcessForm.expressCost[i].disabled=false;
				document.sortProcessForm.locationName[i].disabled=false;
				document.sortProcessForm.normalCycleTime[i].disabled=false;
				document.sortProcessForm.expressCycleTime[i].disabled=false;
				document.sortProcessForm.laserRepairCost[i].disabled=false;
				//document.sortProcessForm.locationName[i].disabled=false;
				str.disabled = false;
				str_raw.disabled = false;

	}
	}

	else{

		str = eval('document.sortProcessForm.select_0');
		str_raw = eval('document.sortProcessForm.laserRepairAllowed_0');
		document.sortProcessForm.priority.disabled=false;
		document.sortProcessForm.split.disabled=false;
		document.sortProcessForm.capacityWeek.disabled=false;
		document.sortProcessForm.normalCost.disabled=false;
		document.sortProcessForm.expressCost.disabled=false;
		document.sortProcessForm.locationName.disabled=false;
		document.sortProcessForm.normalCycleTime.disabled=false;
		document.sortProcessForm.expressCycleTime.disabled=false;
		//document.sortProcessForm.locationName.disabled=false;
		document.sortProcessForm.laserRepairCost.disabled=false;
		str.disabled		= false;
		str_raw.disabled	= false;
	    }
		document.sortProcessForm.submit();
}